package com.tao.encap;

public class Account {
    private String name;
    private double money;
    private String password;

    public Account() {
    }

    public Account(String name, double money, String password) {
        this.setName(name);
        this.setMoney(money);
        this.setPassword(password);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if(name.length() == 2 || name.length() == 3 || name.length() == 4){
            this.name = name;
        }else{
            System.out.println("名字设置不对，需要为（2,3,4）");
            this.name = "无名";
        }

    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        if (money > 20){
            this.money = money;
        }else{
            System.out.println("钱设置不对，需要大于20");
            this.money = 66;
        }

    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        if(password.length()==6){
            this.password = password;
        }else{
            System.out.println("密码设置不对，需要为6位");
            this.password = "123456";
        }

    }

    public String info(){
        return "姓名："+this.name+"，余额："+this.money+"，密码："+this.password;
    }
}